from mm_caps import driver,By,sleep

from appium.webdriver.common.touch_action import TouchAction

# 点击 我的
driver.find_element(By.ID, 'com.mymoney:id/account_centre_icon_default_iv').click()
# 滑动页面
y1 = driver.get_window_size()['height'] * 0.3
x1 = driver.get_window_size()['width'] * 0.5
y2 = driver.get_window_size()['height'] * 0.7
driver.swipe(x1, y2, x1, y1)
sleep(3)
# 点击 设置
driver.find_element(By.XPATH, '//android.widget.TextView[@text="设置"]').click()
# 点击 密码保护
driver.find_element(By.XPATH, '//android.widget.TextView[@text="密码保护"]').click()
sleep(1)
# 开启 密码保护
driver.find_element(By.ID, 'com.mymoney:id/right_switch').click()
# 开启 手势密码
driver.find_element(By.XPATH, '//android.widget.TextView[@text="手势密码"]').click()
sleep(3)

# 设置手势
for i in range(2):
    TouchAction(driver).press(x=251.6, y=383.7).wait(1000).move_to(x=448.5, y=383.7).wait(1000).move_to(
        x=645.2, y=383.7).wait(1000).move_to(x=448.5, y=580.5).wait(1000).move_to(x=251.6, y=776.5).wait(
        1000).move_to(x=448.5, y=776.5).wait(1000).move_to(x=645.2, y=776.5).wait(1000).release().perform()
    sleep(3)

# 输入邮箱
driver.find_element(By.ID, 'com.mymoney:id/email_eactv').send_keys('1969284051@qq.com')
driver.find_element(By.ID, 'com.mymoney:id/email_again_eactv').send_keys('1969284051@qq.com')
# 点击 确定
driver.find_element(By.ID, 'com.mymoney:id/ok_btn').click()
sleep(5)

driver.quit()
